<?php
if(count($cart_arr) > 0)
{
?>
<table class="cart_tbl" cellpadding="2" cellspacing="1" width="98%" style="line-height: 32px;">
	<tr>
		<td colspan="5">Shopping Cart</td>
	</tr>
	<tr>
		<td><b>Item</b></td>
		<td><b>Unit Price(LKR)</b></td>
		<td><b>Quantity</b></td>
		<td><b>Total(LKR)</b></td>
		<td>&nbsp;</td>
	</tr>

<?php
	$tot = "";
	
	foreach ($cart_arr as $cart_entry) :
		$unit_price = $cart_entry['price'];
		$qty = $cart_entry['quantity'];
		$subtotal = $cart_entry['SUBTOTAL'];
?>    		
		<div id="msgbox" style="display: none;"></div>     						
		<tr>
			<td><?php echo $cart_entry['product_title']; ?></td>
			<td width="15%" align="right"><?php echo number_format($cart_entry['price'], 2, '.', ','); ?></td>
			<td width="12%" align="center"><input type="text" name="txtQty" id="txtQty" value="<?php echo $qty; ?>" maxlength="5" size="2" onkeyup="updateQty('<?php echo $cart_entry['product_id']; ?>', this.value, '<?php echo $cart_entry['cart_id']; ?>')" class="quantity" /></td>			
			<td width="12%" align="right">
				<?php
					$item_price = $unit_price * $qty;
					$price = number_format($item_price, 2, '.', ',');
					echo $price; //do not delete
					$tot = $tot + $item_price;
					$subtotal = number_format($tot, 2, '.', ',');						
				?>							
			</td>
			<td align="center" width="5%"><a href="javascript: void(0);" onclick="delCartItem('<?php echo $cart_entry['product_id']; ?>', '<?php echo $cart_entry['cart_id']; ?>')"><img src="<?php echo SITEURL; ?>images/delete.png" alt="remove from cart" /></a></td>
		</tr>					
					                        
	<?php	
		endforeach;
	?>
	<tr>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		<td align="center">Sub Total</td>
		<td align="right"><?php echo $subtotal; ?></td>		
	</tr>
	<tr>
		<td colspan="4" align="right">&nbsp;</td>
	</tr>		
</table>
<?php
} else {
	echo "This cart is empty.";
}
?>
<table width="98%" border="0" cellpadding="2" cellspacing="1">
	<tr>
		<td colspan="3"></td>
	</tr>
	<tr>
		<td colspan="3">&nbsp;</td>
	</tr>
	<tr>
		<td align="center"><!--<a href="<?php //echo SITEURL; ?>index.php/?products/<?php //echo $cart_entry['cart_id']; ?>">Continue on shopping</a>-->
		<form method="POST" action="<?php echo SITEURL; ?>index.php/?products">
			<input type="submit" name="btnContinue" id="btnContinue" value="Continue on Shopping" />
			<input type="hidden" name="savecartid" id="savecartid" value="<?php echo $cart_entry['cart_id']; ?>" />
		</form>
		</td>		
		<td align="center"><!--<a href="<?php //echo SITEURL; ?>index.php/?checkout/savecart">Proceed to checkout</a>-->
		<form method="POST" action="<?php echo SITEURL; ?>index.php/?checkout">	
			<input type="submit" name="btnProceed" id="btnProceed" value="Proceed to Checkout" />
			<input type="hidden" name="savecartid" id="savecartid" value="<?php echo $cart_entry['cart_id']; ?>" />
		</form>
		</td>
		<td align="center"><input type="button" name="btnDelCart" id="btnDelCart" value="Delete Cart" onclick="delSavedCart('<?php echo $param1; ?>');" /></td>
	</tr>
</table>
